package com.ssy.lingxi.order.controller.platform;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.order.model.dto.OrderMemberQueryDTO;
import com.ssy.lingxi.order.model.vo.platform.request.*;
import com.ssy.lingxi.order.model.vo.platform.response.PlatformPaymentDetailVO;
import com.ssy.lingxi.order.model.vo.platform.response.PlatformPaymentPayTypeQueryVO;
import com.ssy.lingxi.order.model.vo.platform.response.PlatformPaymentQueryVO;
import com.ssy.lingxi.order.service.platform.IPlatformPaymentService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 平台后台 - 会员支付策略相关接口
 * @author 万宁
 * @version 2.0.0
 * @date 2021-08-11
 */
@RestController
@RequestMapping("/order/platform/payment")
public class PlatformPaymentController {
    @Resource
    private IPlatformPaymentService platformPaymentService;

    /**
     * 分页查询支付策略列表
     * @param headers HttpHeaders信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public Wrapper<PageData<PlatformPaymentQueryVO>> pagePayments(@RequestHeader HttpHeaders headers, @Valid PlatformPaymentPageVO pageVO) {
        return platformPaymentService.pagePayments(headers, pageVO);
    }

    /**
     * 新增页面，查询支付方式与支付渠道列表
     * @param headers HttpHeaders信息
     * @return 查询结果
     */
    @RequestMapping(value = "/items", method = RequestMethod.GET)
    public Wrapper<List<PlatformPaymentPayTypeQueryVO>> getPaymentItems(@RequestHeader HttpHeaders headers) {
        return platformPaymentService.getPaymentItems(headers);
    }

    /**
     * 新增会员支付策略
     * @param headers HttpHeaders信息
     * @param paymentVO 接口参数
     * @return 新增结果
     */
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public Wrapper<Void> createPayment(@RequestHeader HttpHeaders headers, @RequestBody @Valid PlatformPaymentVO paymentVO) {
        return platformPaymentService.createPayment(headers, paymentVO);
    }

    /**
     * 查询会员支付策略详情
     * @param headers HttpHeaders信息
     * @param idVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/detail", method = RequestMethod.GET)
    public Wrapper<PlatformPaymentDetailVO> getPayment(@RequestHeader HttpHeaders headers, @Valid PlatformPaymentIdVO idVO) {
        return platformPaymentService.getPayment(headers, idVO);
    }

    /**
     * 修改会员支付策略
     * @param headers HttpHeaders信息
     * @param updateVO 接口参数
     * @return 修改结果
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Wrapper<Void> updatePayment(@RequestHeader HttpHeaders headers, @RequestBody @Valid PlatformPaymentUpdateVO updateVO) {
        return platformPaymentService.updatePayment(headers, updateVO);
    }

    /**
     * 分页查询支付策略适用会员列表
     * @param headers HttpHeaders信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/member/page", method = RequestMethod.GET)
    public Wrapper<PageData<OrderMemberQueryDTO>> pagePaymentMembers(@RequestHeader HttpHeaders headers, @Valid PlatformPaymentMemberPageVO pageVO) {
        return platformPaymentService.pagePaymentMembers(headers, pageVO);
    }

    /**
     * 修改会员支付策略状态
     * @param headers HttpHeaders信息
     * @param statusVO 接口参数
     * @return 修改结果
     */
    @RequestMapping(value = "/status", method = RequestMethod.POST)
    public Wrapper<Void> updatePaymentStatus(@RequestHeader HttpHeaders headers, @RequestBody @Valid PlatformPaymentUpdateStatusVO statusVO) {
        return platformPaymentService.updatePaymentStatus(headers, statusVO);
    }

    /**
     * 删除会员支付策略
     * @param headers HttpHeaders信息
     * @param idVO 接口参数
     * @return 删除结果
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public Wrapper<Void> deletePayment(@RequestHeader HttpHeaders headers, @RequestBody @Valid PlatformPaymentIdVO idVO) {
        return platformPaymentService.deletePayment(headers, idVO);
    }
}
